package com.thb.pay.manage.web.payment;


import com.thb.pay.api.payment.PayProductServiceApi;
import com.thb.pay.api.payment.vo.req.PayProductPageReq;
import com.thb.pay.api.payment.vo.req.PayProductReq;
import com.thb.pay.api.payment.vo.resp.PayProductVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.core.utils.R;
import com.thb.pay.manage.comm.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 支付-产品表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@Slf4j
@RestController
@RequestMapping("api/sys/payProduct")
public class PayProductController extends BaseController {

    @Autowired
    private PayProductServiceApi payProductServiceApi;

    @PostMapping("/list")
    public R list(@RequestBody PayProductPageReq pageReq) {
        PageResult<PayProductVo> pageResult = payProductServiceApi.findPage(pageReq);
        return R.okData(pageResult);
    }

    @RequestMapping("/get")
    public R get(@RequestParam("id") Long id) {
        PayProductVo resultData = payProductServiceApi.getById(id);
        return R.okData(resultData);
    }

    @PostMapping("/add")
    public R add(@RequestBody PayProductReq payProductReq) {
        payProductServiceApi.add(payProductReq);
        return R.ok();
    }

    @PostMapping("/update")
    public R update(@RequestBody PayProductReq payProductReq) {
        payProductServiceApi.update(payProductReq);
        return R.ok();
    }
}
